package com.djx;

import com.djx.dao.BookDao;
import com.djx.dao.impl.BookDaoImpl;
import com.djx.domian.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.sql.DataSource;
import java.util.List;

@SpringBootTest
public class test {

    @Autowired
    BookDao bookDao;

    @Autowired
    DataSource dataSource;

    @Test
    public void testSave() {
        Book book = new Book();
        book.setType("数学");
        book.setName("高等数学");
        book.setDescription("这个是高等数学书");
        bookDao.save(book);
    }
    @Test
    public void testUpdate() {
        Book book = new Book();
        book.setId(16);
        book.setType("数学");
        book.setName("高等数学上");
        book.setDescription("这个是高等数学书");
        bookDao.update(book);
    }
    @Test
    public void testDelete() {
        bookDao.delete(17);
    }
    @Test
    public void testGetAll() {
        List<Book> books = bookDao.getAll();
        System.out.println(books);
    }

}
